package com.jason.www.enums;

import java.util.HashMap;
import java.util.Map;


public enum PayType {



    NEWALIPAY((byte) 1, "支付宝支付", "newAlipayClient"),
    UNIONPAY((byte) 2, "银联支付", "unionpayClient"),
    WXPAY((byte) 3, "微信","wxpayClient");

    private Byte code;
    private String desc;
    private String client;
    private static Map<Byte, PayType> map = new HashMap<>();

    static {
        if (map == null) {
            map = new HashMap<>();
        }
        for (PayType e : PayType.values()) {
            map.put(e.getCode(), e);
        }
    }

    PayType(byte code, String desc, String client) {
        this.code = code;
        this.desc = desc;
        this.client = client;
    }

    public Byte getCode() {
        return code;
    }

    public void setCode(Byte code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public static PayType getPayType(Byte type) {
        return map.get(type);
    }



    public static String getCodeName(Byte status) {
        String retCodeName = "";
        for (PayType ss : PayType.values()) {
            if (ss.getCode().equals(status)) {
                retCodeName = ss.getDesc();
                break;
            }
        }
        return retCodeName;
    }
}
